<?php


namespace api\home\controller;


use api\home\model\NewsModel;
use cmf\controller\RestBaseController;

class NewsController extends RestBaseController
{
    public function getNewsList()
    {

        //获取页数与每页数
        $page = input('page/d',1);
        $pageSize = input('page_size/d',1);

        $list = NewsModel::order('list_order','desc')
            ->field('id,title,image,abstract')
            ->page($page,$pageSize)
            ->select();

        $this->success('院系新闻列表',$list);

    }
    public function getNewsContent()
    {

        $id = input('id',3);

        if(!$id){
            $this->error('未查询到数据');
        }

        $list = NewsModel::withoutField('list_order,delete_time,update_time,create_time')
            ->find($id);

        //富文本处理
        $content = htmlspecialchars_decode($list['content']);
        $content1 = cmf_replace_content_file_url($content);
        $list['content'] = $content1;

        $this->success('正文详情显示',$list);
    }
}